package cn.hbu.zlfw.research.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.NotBlank;

import com.fasterxml.jackson.annotation.JsonIgnore;

import cn.hbu.zlfw.patent.entity.Patent;


/**
 * 
 * @ClassName: Researcher 
 * @Description: 科研人员实体类
 * @author 王鹏伟<1223443289@qq.com>
 * @date 2017年10月23日 下午5:27:43  
 * @version V1.0
 */
@Entity
@Table(name="t_researcher")
public class Researcher implements Serializable{

	private static final long serialVersionUID = 5143588983960428156L;
	
	@Id
	@Column(name="id",length=32)
	@GeneratedValue(generator="UUID_KEY")
	@GenericGenerator(name="UUID_KEY",strategy="uuid.hex")
	private String id;
	
	@Column(name="userType",length=20,nullable=false)
	private Integer userType;
	
	@NotBlank(message = "{NotBlank.researcher.userName}")
	@Column(name="userName",length=100,nullable=false)
	private String userName;
	
	@NotNull(message = "{NotNull.researcher.schoolType}")
	@Column(name="schoolType",length=20,nullable=false)
	private Integer schoolType;	//单位类型编码
	
	@NotBlank(message = "{NotBlank.researcher.department}")
	@Column(name="department",length=80,nullable=false)
	private String department;	//部门
	
	@Pattern(regexp="^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$",message= "{Pattern.researcher.email}")
	@Column(name="email",length=100,nullable=false)
	private String email;
	
	@Pattern(regexp="\\d{11}",message= "{Pattern.researcher.phoneNumber}")
	@Column(name="phoneNumber",length=100,nullable=false)
	private String phoneNumber;
	
	@Size(min=8,max=20,message = "{Size.researcher.password}")
	@Column(name="password",length=100,nullable=false)
	private String password;
	
	@NotBlank(message = "{NotBlank.researcher.research}")
	@Column(name="research",nullable=false)
	private String research;	//研究方向
	
	@Column(name="QQ",length=100)
	private String QQ;	//QQ
	
	@Column(name="weChat",length=100)
	private String weChat;	//微信
	
	@Column(name="delState",length=20,nullable=false)
	private Integer delState;	//删除状态：1表示已删除，0表示未删除

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="createTime",nullable=false)
	private Date createTime;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="updateTime",nullable=false)
	private Date updateTime;
	
	@OneToMany(mappedBy="researcher")
	@JsonIgnore
	private Set<Patent> patents;	//专利

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public Integer getUserType() {
		return userType;
	}

	public void setUserType(Integer userType) {
		this.userType = userType;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Integer getSchoolType() {
		return schoolType;
	}

	public void setSchoolType(Integer schoolType) {
		this.schoolType = schoolType;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getResearch() {
		return research;
	}

	public void setResearch(String research) {
		this.research = research;
	}

	public String getQQ() {
		return QQ;
	}

	public void setQQ(String qQ) {
		QQ = qQ;
	}

	public String getWeChat() {
		return weChat;
	}

	public void setWeChat(String weChat) {
		this.weChat = weChat;
	}
	
	public Integer getDelState() {
		return delState;
	}

	public void setDelState(Integer delState) {
		this.delState = delState;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	public Set<Patent> getPatents() {
		return patents;
	}

	public void setPatents(Set<Patent> patents) {
		this.patents = patents;
	}
	@Override
	public String toString() {
		return "Researcher [id=" + id + ", userType=" + userType + ", userName=" + userName + ", schoolType="
				+ schoolType + ", department=" + department + ", email=" + email + ", phoneNumber=" + phoneNumber
				+ ", password=" + password + ", research=" + research + ", QQ=" + QQ + ", weChat=" + weChat
				+ ", delState=" + delState + ", createTime=" + createTime + ", updateTime=" + updateTime + "]";
	}

}
